**************************************************************************************************
*** This do file creates the replication results for 
*** Authors in alphabetical order: Eric Neumayer, Thomas Pluemper, Matthew Shaikh.
*** The Logics of Covid-19 Travel Restrictions between European Countries  
*** Social Science Quarterly, First published: 07 August 2021 https://doi.org/10.1111/ssqu.13016 
							
**************************************************************************************************
**************************************************************************************************
/* Note: You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 
/* You must have Stata version 13 or higher installed													*/
**************************************************************************************************
*/

drop _all
clear matrix
clear mata


capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o) /* checks whether outreg2 is installed 		*/


***********************************************************************************
local DIR = "D:\Research\Health for all database\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************


use "Article for SSQ (Covid-19 travel restrictions).dta", clear

capture drop  symmetric_sample
gen symmetric_sample=1
replace symmetric_sample=0 if target_j=="Iceland"
replace symmetric_sample=0 if target_j=="Liechtenstein"
replace symmetric_sample=0 if target_j=="Luxembourg"
replace symmetric_sample=0 if target_j=="Malta"
replace symmetric_sample=0 if target_j=="Cyprus"
label var symmetric_sample "=1 if country is both actor and target"

** Table 1: Estimation results

* July
logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1 & month==7,  cluster(target_j)
mtable, at((p25) diff_incidence_j_i)
mtable, at((p75) diff_incidence_j_i) 
mtable, at((p25) containmenthealthindex)
mtable, at((p75) containmenthealthindex) 
mtable, at((p25) tour_inc_gdp)
mtable, at((p75) tour_inc_gdp) 
mtable, at((p25) trust_gov_pubadmin_2020)
mtable, at((p75) trust_gov_pubadmin_2020) 
mtable, at((p25) numberofpartytypes)
mtable, at((p75) numberofpartytypes)

outreg2 using table1, excel 2aster replace e(r2_p)
estat class, cutoff(0.5)
capture drop correct_class
capture drop p_prob_7 
predict p_prob_7 if month==7
gen correct_class = (p_prob_7 > 0.5) == travel_restriction_0_1
sum travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if e(sample)

* August
logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1 & month==8,  cluster(target_j)
mtable, at((p25) diff_incidence_j_i)
mtable, at((p75) diff_incidence_j_i) 
mtable, at((p25) containmenthealthindex)
mtable, at((p75) containmenthealthindex) 
mtable, at((p25) tour_inc_gdp)
mtable, at((p75) tour_inc_gdp) 
mtable, at((p25) trust_gov_pubadmin_2020)
mtable, at((p75) trust_gov_pubadmin_2020) 
mtable, at((p25) numberofpartytypes)
mtable, at((p75) numberofpartytypes)

outreg2 using table1, excel 2aster append e(r2_p)
estat class, cutoff(0.5)
capture drop p_prob_8 
predict p_prob_8 if month==8
replace correct_class = (p_prob_8 > 0.5) == travel_restriction_0_1 if month==8
sum travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if e(sample)

* September
logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp  trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1 & month==9,  cluster(target_j)
mtable, at((p25) diff_incidence_j_i)
mtable, at((p75) diff_incidence_j_i) 
mtable, at((p25) containmenthealthindex)
mtable, at((p75) containmenthealthindex) 
mtable, at((p25) tour_inc_gdp)
mtable, at((p75) tour_inc_gdp) 
mtable, at((p25) trust_gov_pubadmin_2020)
mtable, at((p75) trust_gov_pubadmin_2020) 
mtable, at((p25) numberofpartytypes)
mtable, at((p75) numberofpartytypes)


outreg2 using table1, excel 2aster append e(r2_p)
estat class, cutoff(0.5)
capture drop p_prob_9 
predict p_prob_9 if month==9
replace correct_class = (p_prob_9 > 0.5) == travel_restriction_0_1 if month==9
sum travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if e(sample)

* October
logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1 & month==10,  cluster(target_j)
mtable, at((p25) diff_incidence_j_i)
mtable, at((p75) diff_incidence_j_i) 
mtable, at((p25) containmenthealthindex)
mtable, at((p75) containmenthealthindex) 
mtable, at((p25) tour_inc_gdp)
mtable, at((p75) tour_inc_gdp) 
mtable, at((p25) trust_gov_pubadmin_2020)
mtable, at((p75) trust_gov_pubadmin_2020) 
mtable, at((p25) numberofpartytypes)
mtable, at((p75) numberofpartytypes)


outreg2 using table1, excel 2aster append e(r2_p)
estat class, cutoff(0.5)
capture drop p_prob_10 
predict p_prob_10 if month==10
replace correct_class = (p_prob_10 > 0.5) == travel_restriction_0_1 if month==10
sum travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if e(sample)

* November
logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1 & month==11,  cluster(target_j)
mtable, at((p25) diff_incidence_j_i)
mtable, at((p75) diff_incidence_j_i) 
mtable, at((p25) containmenthealthindex)
mtable, at((p75) containmenthealthindex) 
mtable, at((p25) tour_inc_gdp)
mtable, at((p75) tour_inc_gdp) 
mtable, at((p25) trust_gov_pubadmin_2020)
mtable, at((p75) trust_gov_pubadmin_2020) 
mtable, at((p25) numberofpartytypes)
mtable, at((p75) numberofpartytypes)


outreg2 using table1, excel 2aster append e(r2_p)
estat class, cutoff(0.5)
capture drop p_prob_11 
predict p_prob_11 if month==11
replace correct_class = (p_prob_11 > 0.5) == travel_restriction_0_1 if month==11
sum travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if e(sample)

* December
logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1 & month==12,  cluster(target_j)
mtable, at((p25) diff_incidence_j_i)
mtable, at((p75) diff_incidence_j_i) 
mtable, at((p25) containmenthealthindex)
mtable, at((p75) containmenthealthindex) 
mtable, at((p25) tour_inc_gdp)
mtable, at((p75) tour_inc_gdp) 
mtable, at((p25) trust_gov_pubadmin_2020)
mtable, at((p75) trust_gov_pubadmin_2020) 
mtable, at((p25) numberofpartytypes)
mtable, at((p75) numberofpartytypes)


outreg2 using table1, excel 2aster append e(r2_p)
estat class, cutoff(0.5)
capture drop p_prob_12 
predict p_prob_12 if month==12
replace correct_class = (p_prob_12 > 0.5) == travel_restriction_0_1 if month==12
sum travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if e(sample)

** All
logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1,  cluster(target_j)
mtable, at((p25) diff_incidence_j_i)
mtable, at((p75) diff_incidence_j_i) 
mtable, at((p25) containmenthealthindex)
mtable, at((p75) containmenthealthindex) 
mtable, at((p25) tour_inc_gdp)
mtable, at((p75) tour_inc_gdp) 
mtable, at((p25) trust_gov_pubadmin_2020)
mtable, at((p75) trust_gov_pubadmin_2020) 
mtable, at((p25) numberofpartytypes)
mtable, at((p75) numberofpartytypes)





** Table 2: Correctly classified
preserve
quietly logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1,  cluster(target_j)
keep if e(sample)
bys actor_i: sum correct_class if e(sample)
bys target_j: sum correct_class if e(sample)
restore


** Appendix 1
preserve
quietly logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1 & month==7,  cluster(target_j)
keep if e(sample)
collapse travel_restriction_0_1, by(actor_i)
list actor_i
restore


** Appendix 2
quietly logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1,  cluster(target_j)
sum travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if e(sample), detail



** Additional tests
use "Article for SSQ (Covid-19 travel restrictions).dta", clear
preserve
quietly logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1,  cluster(target_j)
keep if e(sample)
keep if travel_restriction_0_1==0
bys actor_i month: egen inc_j_max=max(incidence_j)
bys actor_i month: keep if incidence_j==inc_j_max
keep actor_i target_j month incidence_i incidence_j diff_incidence_j_i
sort actor_i month target_j  incidence_i incidence_j diff_incidence_j_i
list actor_i target_j month incidence_i incidence_j diff_incidence_j_i
save "max incidence_j without travel restriction", replace
restore

use "Article for SSQ (Covid-19 travel restrictions).dta", clear
preserve
quietly logit travel_restriction_0_1  diff_incidence_j_i containmenthealthindex tour_inc_gdp trust_gov_pubadmin_2020 numberofpartytypes if symmetric_sample==1,  cluster(target_j)
keep if e(sample)
keep if travel_restriction_0_1==1
bys actor_i month: egen inc_j_min=min(incidence_j)
bys actor_i month: keep if incidence_j==inc_j_min
keep actor_i target_j month incidence_i incidence_j diff_incidence_j_i
sort actor_i month target_j  incidence_i incidence_j diff_incidence_j_i
list actor_i target_j month incidence_i incidence_j diff_incidence_j_i
save "min incidence_j with travel restriction", replace
restore


